package com.suxin.splitter.executor;

import com.suxin.splitter.MethodExecutor;

import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author Tang
 * @classname SerialMethodExecutor
 * @description [ 顺序执行器 ]
 * @date 2022/11/7 13:50
 */
public class SerialMethodExecutor extends AbstractMethodExecutor implements MethodExecutor {

    @Override
    protected <P, R> List<R> doExecute(Function<P, R> function, List<P> ps) {
        return ps.stream()
                .map(function::apply)
                .collect(Collectors.toList());
    }
}
